#pragma  once

namespace MomogenkyouSystem	{

	class BatchedQuad	:	public	IBatch
{
	static	INDEXBUFFER		g_IndexBuffer;

protected:
	VERTEXBUFFER			m_VertexBuffer;		//	VertexBuffer, data in it may be discarded for newer draw calls
	Vertex			*		m_pVertexMemory;
	size_t					m_iCurrentCount;
public:
	BatchedQuad();
	virtual ~BatchedQuad();

	//	Amount of vertices in the buffer
	inline	size_t			CurrentVertexCount()	const	{	return	m_iCurrentCount;		}
	//	Amount of quads in the buffer
	inline	size_t			CurrentQuadCount()		const	{	return	m_iCurrentCount << 2;	}
	
	//	Create a global Index Buffer
	static	void	PrepareIndexBuffer();
	//	Release a global Index Buffer
	static	void	ReleaseIndexBuffer();

	//	Prepare the device for rendering Batches
	static	void	PrepareRender();

	virtual	void	Initialize();
	virtual	void	Shutdown();

	//	Lock the Batch, Try to minimize calls
	virtual	void	Lock();
	//	Unlock the Batch, this should match the number of Lock Calls
	virtual	void	Unlock();

	//	Feed Vertices into this Batch call
	//	@param	pData		Specify Pointer to vertices.
	//	@param	pDataCount	Specify amount of vertices to feed.
	virtual	void	Feed(	const	void	*	pData,
							const	size_t		iDataCount);

	//	Draws the Batch, try not to call this if Not feeding anything.
	virtual	void	Render();
};

}